package 线程状态.线程礼让;

public class test implements Runnable{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+"-->线程开始");
        if (Thread.currentThread().getName().equals("A")) {
            Thread.yield();//线程礼让
            System.out.println("A礼让了B");
        }
        System.out.println(Thread.currentThread().getName()+"-->线程结束");
    }

    public static void main(String[] args) {
        test test = new test();
        new Thread(test,"A").start();
        new Thread(test,"B").start();
    }
}
